package com.zlm.user.emp.service.impl;

import com.zlm.common.base.AbstractBaseService;
import com.zlm.common.entity.EmpUserEducationDO;
import com.zlm.common.enums.EducationEnum;
import com.zlm.user.emp.dao.EmpUserEducationDao;
import com.zlm.user.emp.service.EmpUserEducationService;
import com.zlm.user.emp.util.EmpUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Author: duyufu
 * @Date: 2019/5/14 16:51
 */
@Service
public class EmpUserEducationServiceImpl extends AbstractBaseService<EmpUserEducationDao, EmpUserEducationDO> implements EmpUserEducationService {

    @Autowired
    @Override
    public void setBaseDao(EmpUserEducationDao empUserEducationDao) {
        this.baseDao = empUserEducationDao;
    }


    @Override
    public void insertUserEducation(EmpUserEducationDO empUserEducationDO) {
        baseDao.insertUserEducation(empUserEducationDO);
        EmpUtils.updateEmpPerfect(empUserEducationDO.getEmpId());
    }

    @Override
    public void updateUserEducation(EmpUserEducationDO empUserEducationDO) {
        baseDao.updateUserEducation(empUserEducationDO);
        EmpUtils.updateEmpPerfect(empUserEducationDO.getEmpId());
    }

    @Override
    public void deleteUserEducation(Integer empId, Integer eid) {
        baseDao.deleteUserEducation(empId,eid);
        EmpUtils.updateEmpPerfect(empId);
    }

    @Override
    public List<EmpUserEducationDO> queryUserEducation(Integer empId) {
        List<EmpUserEducationDO> educationList = baseDao.queryUserEducation(empId);
        for (EmpUserEducationDO empUserEducationDO : educationList) {
            empUserEducationDO.setDegreeName(EducationEnum.getNameByCode(empUserEducationDO.getDegree()));
        }
        return educationList;
    }
}
